package mt.ordersList;

import javax.swing.JTextArea;

import mt.Order;

public class OrdersLog {
	
	/**
	 * {@link JTextArea} object, the log will be stored here
	 */
	private JTextArea logTextArea;
	
	/**
	 * {@link OrdersLog} constructor
	 */
	public OrdersLog() {
		
		logTextArea = new JTextArea();
		logTextArea.setEditable(false);
		
	}
	
	/**
	 * Appends to the log the error information
	 * @param errorMessage
	 */
	public void addError(String errorMessage) {
		logTextArea.append("\n"+"[RECEIVED] Error message: "+errorMessage);
	}
	
	
	/**
	 * Appends to the log the new order update
	 * @param order
	 */
	public void addUpdate(Order order){
		
		logTextArea.append("\n"+"[RECEIVED] Order Update: "+order.toString());
		
	}
	
	/**
	 * Appends to the log the new order received
	 * @param order
	 */
public void addNewOrder(Order order){
		
	logTextArea.append("\n"+"[RECEIVED] New order: "+order.toString());
		
	}

/**
 * Appends to the log the order that was removed
 * @param order
 */
public void addRemoveOrder(Order order){
	
	logTextArea.append("\n"+"[RECEIVED] Order removed: "+order.toString());
		
	}


/**
 * Appends to the log the new order created by the user and sent to the server
 * @param order
 */
public void sentOrder(Order order){
	logTextArea.append("\n"+"[SENT] New order created and sent: "+order.toString());

}


/**
 * 
 * @return the {@link JTextArea} that contains the log information
 */
public JTextArea getLogTextArea() {
	return logTextArea;
}	

}
